import Vue from 'vue' //引入Vue
import Router from 'vue-router' //引入vue-router

/* Layout */
import Layout3 from '@/layout/Layout3' //引入想要的组件


Vue.use(Router) //Vue全局使用Router


export const constantRouterMap = [ //配置路由，这里是个数组


    {
        path: '/login',
        name: '登录',
        hidden: true,
        component: () =>
            import ('@/views/login/index'),
    },

    {
        path: '/',
        component: Layout3,
        redirect: '/dashboard',
        name: '首页',
        hidden: false,
        children: [{
            path: 'dashboard',
            component: () =>
                import ('@/views/home/home'),
            name: '首页', //路由名称
            hidden: false,
            meta: {
                title: '首页',
                icon: 'el-icon-s-home',
                affix: true,

            }
        }, ]
    },

    {
        path: '/project',
        component: Layout3,
        redirect: '/projectManager',
        name: '项目管理',
        hidden: false,
        children: [{
            path: 'projectManager',
            component: () =>
                import ('@/views/interface/project/projectManager'),
            name: '项目管理', //路由名称
            hidden: false,
            meta: {
                title: '项目管理',
                icon: 'el-icon-s-flag',
                affix: true,
            },

        }]
    },

    {
        path: '/interface',
        component: Layout3,
        redirect: '/interfaceManager',
        name: '接口管理',
        hidden: false,
        children: [{
            path: 'interfaceManager',
            component: () =>
                import ('@/views/interface/interface/interfaceManager'),
            name: '接口管理', //路由名称
            hidden: false,
            meta: {
                title: '接口管理',
                icon: 'el-icon-s-management',
                affix: true,

            }
        }, {
            path: 'interfaceManagerDesc',
            component: () =>
                import ('@/views/interface/interface/interfaceManager'),
            name: '接口概况', //路由名称
            hidden: false,
            meta: {
                title: '接口概况',
                icon: 'el-icon-s-flag',
                affix: true,

            },

        }]
    },

    {
        path: '/case',
        component: Layout3,
        redirect: '/caseManager',
        name: '用例管理',
        hidden: false,
        children: [{
            path: 'caseManager',
            component: () =>
                import ('@/views/interface/case/caseManager'),
            name: '单用例管理', //路由名称
            hidden: false,
            meta: {
                title: '单用例管理',
                icon: 'el-icon-s-management',
                affix: true,

            }
        }, {
            path: 'interfaceManagerDesc',
            component: () =>
                import ('@/views/interface/case/caseManager'),
            name: '多用例管理', //路由名称
            hidden: false,
            meta: {
                title: '多用例管理',
                icon: 'el-icon-s-flag',
                affix: true,

            },

        }]
    },

    {
        path: '/env',
        component: Layout3,
        redirect: '/env',
        name: '环境配置',
        hidden: false,
        children: [{
            path: 'env',
            component: () =>
                import ('@/views/interface/env/envManager'),
            name: '环境配置', //路由名称
            hidden: false,
            meta: {
                title: '环境配置',
                icon: 'el-icon-s-flag',
                affix: true,

            },

        }]
    },

    {
        path: '/function',
        component: Layout3,
        redirect: '/function',
        name: '功能菜单',
        hidden: false,
        children: [{
                path: 'function',
                component: () =>
                    import ('@/views/curriculum/directives'),
                name: '常用指令',
                meta: {
                    title: '常用指令',
                    icon: 'el-icon-s-tools',
                    affix: true
                }
            },

            {
                path: 'calculationProperties',
                component: () =>
                    import ('@/views/curriculum/calculationProperties'),
                name: '计算属性',
                meta: {
                    title: '计算属性',
                    icon: 'dashboard',
                    affix: true
                }
            },

            {
                path: 'DynamicCSS',
                component: () =>
                    import ('@/views/curriculum/dynamicCSS'),
                name: '动态样式绑定',
                meta: {
                    title: '动态样式绑定',
                    icon: 'dashboard',
                    affix: true
                }
            },


            {
                path: 'watch',
                component: () =>
                    import ('@/views/curriculum/watch'),
                name: '倾听器',
                meta: {
                    title: '倾听器',
                    icon: 'dashboard',
                    affix: true
                }
            },


            {
                path: 'eventProcessing',
                component: () =>
                    import ('@/views/curriculum/eventProcessing'),
                name: '事件处理',
                meta: {
                    title: '事件处理',
                    icon: 'dashboard',
                    affix: true
                }
            },


            {
                path: 'lifeCycle',
                component: () =>
                    import ('@/views/curriculum/lifeCycle'),
                name: '生命周期',
                meta: {
                    title: '生命周期',
                    icon: 'dashboard',
                    affix: true
                }
            },


            {
                path: 'componentCommunication',
                component: () =>
                    import ('@/views/curriculum/componentCommunication'),
                name: '组件通信',
                meta: {
                    title: '组件通信',
                    icon: 'dashboard',
                    affix: true
                }
            },



            {
                path: 'router',
                component: () =>
                    import ('@/views/curriculum/vueRouter'),
                name: '路由器',
                meta: {
                    title: '路由示例',
                    icon: 'dashboard',
                    affix: true
                }
            },
            {
                path: 'vuex',
                component: () =>
                    import ('@/views/curriculum/vuex'),
                name: 'vuex',
                meta: {
                    title: 'vuex',
                    icon: 'dashboard',
                    affix: true
                }
            },

            {
                path: 'axios',
                component: () =>
                    import ('@/views/axios/axios'),
                name: 'axios请求',
                meta: {
                    title: 'axios请求',
                    icon: 'dashboard',
                    affix: true
                }
            },


            {
                path: 'filters',
                component: () =>
                    import ('@/views/curriculum/filters'),
                name: '过滤器',
                meta: {
                    title: '过滤器',
                    icon: 'dashboard',
                    affix: true
                }
            },
        ]
    },



    {
        path: '/interface/:interface_id',
        component: Layout3,
        redirect: '/interface/:interface_id',
        name: '接口预览',
        hidden: true,
        children: [{
                path: '/interface/:interface_id',
                component: () =>
                    import ('@/views/interface/interface/interface'),
                name: '接口预览', //路由名称
                hidden: true,
                meta: {
                    title: '接口预览',
                    icon: 'el-icon-s-management',
                    affix: true,

                }
            },
            {
                path: '/case/:interface_id',
                component: () =>
                    import ('@/views/interface/case/case'),
                name: '用例预览', //路由名称
                hidden: true,
                meta: {
                    title: '用例预览',
                    icon: 'el-icon-s-management',
                    affix: true,

                }
            }
        ]
    },



]

export default new Router({
    // mode: 'history',
    routes: constantRouterMap
})




//解决异常的
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}